/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kedacom.demo.jmx.book;

import javax.management.MBeanServerConnection;
import javax.management.ObjectName;

/**
 *
 * @author Administrator
 */
public class HelloWorldSetup {

    public HelloWorldSetup() {

        try {
            MBeanServerConnection client = RMIClientFactory.getClient();
            ObjectName hwName = new ObjectName("JMXBookAgent:name=helloWorld");
            client.createMBean("jmxbook.ch2.HelloWorld", hwName);
            client.invoke(hwName, "printGreeting", null, null);  //调用hellowaord MBean里的pirntGreating方法 
            client.unregisterMBean(hwName);
            /**
             * *RmiConnectorClient client = RMIClientFactory.getClient();
             * ObjectName hwName = new ObjectName(
             * "JMXBookAgent:name=helloWorld"); client.createMBean(
             * "jmxbook.ch2.HelloWorld", hwName ); client.invoke( hwName,
             * "printGreeting", null, null );
             */
        }
        catch (Exception e) {

            e.printStackTrace();

        }

    }

    public static void main(String args[]) {

        HelloWorldSetup setup = new HelloWorldSetup();

    }
}
